<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    {include file="../tpl/header.html" /}
</head>
<body>
{include file="../tpl/menu.html" /}
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" method="post" action="{:url('admin/admin/regionAdd')}">

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>上级区域</label>
                <div class="layui-input-inline">
                    <select name="pid">
                        <option value="0">顶级区域</option>
                        {volist name="list" id="vo"}
                        <option value="{$vo['region_code']}">{$vo.mark}{$vo.region_name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>上级区域
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>区域名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="region_name" required="" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>展示的区域名称,不要超过20个字符
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>区域编码</label>
                <div class="layui-input-inline">
                    <input type="text" name="region_code" required="" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>是否有子区域</label>
                <div class="layui-input-block">
                    <input type="radio" value="0" name="has_child" lay-skin="primary" title="否">
                    <input type="radio" value="1" name="has_child" lay-skin="primary" title="是">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>排序号</label>
                <div class="layui-input-inline">
                    <input type="text" required="" lay-verify="required" name="px" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>排序号,系统安装升序排列,小的数字排在前面
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="add" lay-submit="">增加</button>
            </div>
        </form>
    </div>
</div>
<script>
    layui.use(['form','layer'],
    function() {
        $ = layui.jquery;
        var form = layui.form, layer = layui.layer;

        //监听提交
        form.on('submit(add)', function(data) {
            //获取编辑器内容
            $.ajax({
                type:'post',
                data:data.field,
                dataType:'json',
                url:"{:url('admin/admin/regionAdd')}",
                success:function (e) {
                    if(e.code === 1){
                        layer.msg(e.msg, {icon: 6,time: layer_msg_success_time},
                            function() {
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                                parent.location.reload();
                            });
                    }else{
                        layer.msg(e.msg, {icon: 5,time: layer_msg_error_time});
                    }
                }
            });
            //发异步，把数据提交给php
            return false;
        });
    });
</script>
</body>
</html>